#include "RK5.h"

#define N_EQU 2
#define T_START 5.0
#define T_END 10.0
#define STEP_MAX 0.1
#define ERR 1e-6

double fun0(double t,double *x){
	return x[1];
}
double fun1(double t,double *x){
	return -2*x[0]/(t*t)+2*x[1]/t;
}

int main(){
	double x0[N_EQU]={1,4};
	SOLV_PARAM Param={T_START,T_END,x0,STEP_MAX,ERR,N_EQU};
	
	pFUNC Func;
	Func = (pFUNC)malloc(Param.n*sizeof(FUNC));
	Func[0] = fun0;
	Func[1] = fun1;
	
	//Load dll and solver function
	HMODULE SolverDll = LoadLibrary("RK5.dll");
	typedef SOLUTION (*SOLVER)(pFUNC,SOLV_PARAM);
	typedef void (*OUTPUTFUNC)(SOLUTION);
	
	SOLVER Solve;
	Solve = (SOLVER)GetProcAddress(SolverDll,"RK5");
	
	//Solve the equation
	SOLUTION Solution;
	Solution = Solve(Func,Param);
	
	//Output the data
	OUTPUTFUNC Output;
	Output = (OUTPUTFUNC)GetProcAddress(SolverDll,"Output");
	Output(Solution);
	
	free(Func);
	return 0;
}
